<!--基桩工程检测管理--基桩工程信息--编辑-->
<template>
  <div class="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group v-model="radio" size="small" @change="modelType($event)">
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button type="primary" icon="el-icon-refresh" size="small" @click="getDataList(getList)">
            </el-button>
            <el-button type="primary" icon="el-icon-circle-plus-outline" size="small"
              v-if="getList.modelType == '0' && yj_add == true" @click="edit(0)">新增</el-button>
            <el-button type="primary" icon="el-icon-edit" size="small" v-if="getList.modelType == '0' && yj_edit == true"
              @click="edit(1)">编辑</el-button>
            <el-button type="primary" icon="el-icon-circle-check" size="small"
              v-if="getList.modelType == '0' && yj_submit == true" @click="SubmitText(fId)">提交</el-button>
            <el-button type="primary" icon="el-icon-delete" size="small"
              v-if="getList.modelType == '0' && yj_delete == true" @click="rowDelete(fId)">删除</el-button>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <div class="text_table">
        <el-table ref="multipleTable" v-loading="loading" element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.2)"
          @row-click="getRowInfo" :data="tableData" style="width: 100%" height="100%" stripe border highlight-current-row
          @current-change="rowChange">
          <el-table-column fixed type="index" label="序号" width="50" align="center">
          </el-table-column>
          <el-table-column prop="fProjectname" label="项目名称">
            <!-- 超出鼠标滑过显示 -->
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fProjectname">{{
                  scope.row.fProjectname
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fCompanyname" label="施工单位">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fCompanyname">{{
                  scope.row.fCompanyname
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fEngineeringname" label="工程名称">
            <template slot-scope="scope">
              <el-button @click="openDialog(scope.row)" @cell-dblclick="openDialog" type="text" size="small"
                style="padding: 0 !important; margin: 0">
                {{ scope.row.fEngineeringname }}
              </el-button>
            </template>
          </el-table-column>

          <el-table-column prop="fEngineeringlocation" label="工程地点">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fEngineeringlocation">{{ scope.row.fEngineeringlocation }}</a>
              </div>
            </template>
          </el-table-column>

          <el-table-column prop="fPiercount" label="墩台个数" width="70" align="center">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fPiercount">{{
                  scope.row.fPiercount
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fFoundationcount" label="基桩数量" width="70" align="center">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fFoundationcount">{{
                  scope.row.fFoundationcount
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fRegistrantname" label="登记人" width="80" align="center">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fRegistrantname">{{
                  scope.row.fRegistrantname
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fRegistdates" label="登记日期" width="90" align="center">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fRegistdates">{{
                  scope.row.fRegistdates
                }}</a>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="fStatus" label="信息状态" width="80" align="center">
            <template slot-scope="scope">
              <div class="lineBoxhidden">
                <a href="javascript:;" :title="scope.row.fStatus">{{
                  scope.row.fStatus
                }}</a>
              </div>
            </template>
          </el-table-column>
          <template slot="empty">
            <img style="width: 285px; height: 208px" src="@/assets/img/undata.png" alt="" />
            <div class="pageFlagText">暂时没有数据哦！</div>
          </template>
        </el-table>
        <div class="block" v-if="navigatepageNums > 1">
          <!--  -->
          <div class="paginationInfo">
            检索到{{ queryCriteriaData.total }} 条记录 | 显示第
            <span v-if="getList.page == 1">{{ getList.page }}</span><span v-else>{{ 20 * (getList.page - 1) }}</span> -
            <!-- {{ 20 * getList.page }} 条记录 -->
            <span v-if="queryCriteriaData.pages == queryCriteriaData.lastPage"> {{
              queryCriteriaData.total }}</span>
            <span v-else> {{ 20 * getList.page }} </span>
            条记录
          </div>
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :current-page="getList.page" :page-size="getList.pageSize" layout="prev, pager, next, jumper"
            :total="queryCriteriaData.total">
          </el-pagination>
        </div>
      </div>

      <!--弹框 新增/编辑 -->
      <div class="Control-1">
        <el-dialog :title="dialogText"  :visible.sync="dialogTableVisibleText" v-loading="loadingDialogText"
          element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: dialogHeight }">
            <el-form :model="formData" :rules="rules" ref="formData">
              <div class="tableRow">
                <el-form-item label="项目名称" prop="fProjectname" :label-width="formLabelWidth">
                  <el-select @change="function (v) {
                    return selectCompany(v);
                  }
                    " v-model="formData.fProjectname" placeholder="请选择项目">
                    <el-option v-for="v in companyList" :key="v.F_ProjectName" :label="v.F_ProjectName" :value="v">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="施工单位" prop="fCompanyname" :label-width="formLabelWidth">
                  <el-select @change="function (v) {
                    return selectProject(v);
                  }
                    " v-model="formData.fCompanyname" placeholder="选择参建单位">
                    <el-option v-for="v in projectList" :key="v.F_CompanyName" :label="v.F_CompanyName" :value="v">
                    </el-option>
                  </el-select>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="工程名称" prop="fEngineeringname" :label-width="formLabelWidth">
                  <el-input :disabled="dis" v-model="formData.fEngineeringname" autocomplete="off">
                  </el-input>
                </el-form-item>
                <el-form-item label="工程地点" prop="fEngineeringlocation" :label-width="formLabelWidth">
                  <el-input :disabled="dis" v-model="formData.fEngineeringlocation" autocomplete="off"></el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="墩台数量(个)" prop="fPiercount" :label-width="formLabelWidth">
                  <el-input :disabled="dis" v-model="formData.fPiercount" autocomplete="off">
                  </el-input>
                </el-form-item>
                <el-form-item label="基桩数量(根)" prop="fFoundationcount" :label-width="formLabelWidth">
                  <el-input :disabled="dis" v-model="formData.fFoundationcount" autocomplete="off">
                  </el-input>
                </el-form-item>
              </div>
              <div class="tableRow">
                <el-form-item label="登记人" prop="fRegistrantname" :label-width="formLabelWidth">
                  <el-input disabled v-model="formData.fRegistrantname" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="登记日期" prop="fRegistdates" :label-width="formLabelWidth">
                  <el-date-picker :disabled="dis" v-model="formData.fRegistdates" type="date" value-format="yyyy-MM-dd"
                    placeholder="选择日期" autocomplete="off">
                  </el-date-picker>
                </el-form-item>
              </div>
              <el-form-item label="设计文件资料" :label-width="formLabelWidth" class="enclosure">
                <el-input v-show="false" v-model="formData.fCreateusername" autocomplete="off">
                </el-input>
                <div ref="fPhotofilelist" style="
                        height: 25px;
                        line-height: 25px;
                        width: 100%;
                        display: flex;
                        border: 1px solid #d1d7e2;
                        border-radius: 5px;
                        margin: 8px 0 2px 0;
                      ">
                  <div v-for="(item, i) in fPhotofilelist" :key="i" style="margin: 2px 3px; height: 87%"
                    @click="openPdf(item)">
                    <img style="max-width: 100%; max-height: 100%" src="@/assets/img/pdf.png" />
                  </div>
                </div>
                <el-button v-show="flagNum == 0" type="primary" icon="el-icon-search" size="small" @click="operation('1')"
                  style="margin: 8px 0 2px 3px">操作</el-button>
              </el-form-item>

              <el-form-item label="工程信息简述" prop="fEngineeringinfo" :label-width="formLabelWidth">
                <el-input :disabled="dis" v-model="formData.fEngineeringinfo" type="textarea" rows="4" placeholder="请输入内容"
                  autocomplete="off">
                </el-input>
              </el-form-item>

              <el-form-item class="newlyAdded_btn" v-show="flagNum == 0">
                <el-button type="primary" @click="submitForm('formData')">保存</el-button>
                <el-button type="warning" @click="resetForm()">关闭</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-dialog>
      </div>
      <!-- 上传附件  -->
      <div class="Control-1 mechanism_dialog enclosure">
        <el-dialog title="上传附件"  top="17vh" :visible.sync="dialogTableVisibleTexts"
          v-loading="loadingDialogTexts" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '240px' }">
            <el-upload action="action" ref="upload" list-type="picture-card" :file-list="fPhotofilelist"
              :auto-upload="false" :on-change="handleChange" accept=".pdf">
              <i slot="default" class="el-icon-plus"></i>
              <div style="width: 100%; height: 100%; text-align: center" slot="file" slot-scope="{ file }">
                <div style="
                        width: 100%;
                        height: 100%;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                      " class="images">
                  <img style="max-width: 100%; max-height: 100%" src="@/assets/img/pdf.png" />
                </div>
                <span class="el-upload-list__item-actions">
                  <span title="文件预览" class="el-upload-list__item-preview" @click="openPdf(file)">
                    <i class="el-icon-zoom-in"></i>
                  </span>
                  <span title="删除文件" class="el-upload-list__item-delete" @click="handleRemove(file)">
                    <i class="el-icon-delete"></i>
                  </span>
                </span>
              </div>
            </el-upload>
            <div>
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="submitUpload(enclosureImg)">保存</el-button>
                <el-button type="warning" @click="resetFormv()">关闭</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
      <div class="Control-2">
        <el-dialog top="4vh" :title="fFileName"  :visible.sync="dialogPdf">
          <div :style="{ height: dialogHeights }">
            <iframe :src="pdfUrl" width="100%" height="100%" frameborder="0"></iframe>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>
<script>
import {
  getPierProjectPageList, // 基桩工程信息编辑-分页列表页
  addPierProject, // 基桩工程信息编辑编辑-新增/修改 保存按钮接口
  getPierProjectByFid, // 基桩工程信息编辑-详情页
  deletePierProjectByFid, // 基桩工程信息编辑-删除工程信息接口
  // 基桩检测统计获取项目名称
  getProjectIdAndName,
  // 基桩检测统计获取施工单位名称
  getCompanyIdAndName,
  submitPierProject, // 基桩工程信息编辑-编辑-提交按钮接口
  upload,
} from "@/api/request.js";
export default {
  inject: ["reload"],
  name: "Home",
  data() {
    return {
      name: "EngineeringText",
      yj_add: null,
      yj_edit: null,
      yj_delete: null,
      yj_submit: null,
      fPhotofilelist: [],
      dis: false,
      timestamp1: null,
      dialogPdf: false,
      pdfUrl: "",
      fFileName: "",
      companyTree: [],
      projectList: [],
      companyList: [],
      // 列表
      getList: {
        modelType: "0", // 0代办 1已办
        fUserid: null, //当前登录用户id
        page: 1, //页码
        pageSize: 20, //每页条数
      },
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      flagNum: 0,
      // 上传附件
      disabled: false,
      dialogTableVisibleTexts: false,
      loadingDialogTexts: false,
      enclosureImg: {},
      timestamp: null,
      // attachmentDetails: [],
      imgList: [],
      recordfilesList: [],

      // 上传附件
      departmentList: [
        { text: "混凝土回弹检测仪器设备" },
        { text: "钢筋保护层厚度检测设备" },
      ], //外检设备类型
      radio: "待办",
      dialogHeight: "",
      dialogHeights: "",
      fId: null, //当前数据fId
      loading: false,
      userInfo: {}, //登录用户
      // 新增/编辑
      dialogText: "",
      dialogTableVisibleText: false,
      loadingDialogText: false,
      rules: {
        fProjectname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fCompanyname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fEngineeringname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fEngineeringlocation: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fPiercount: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fFoundationcount: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fRegistrantname: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
        fRegistdates: [
          { required: true, message: "请输入机构全称", trigger: "blur" },
        ],
      },
      // 查看
      loadingDialog: false,
      dialogTableVisible: false,
      formData: {
        fId: "", // 工程信息fid  有值时表示修改  其余表示新增
        fCompanyid: "", // 施工单位id
        fCompanyname: "", // 施工单位名称
        fProjectid: "", // 项目id
        fProjectname: "", // 项目名称
        fEngineeringname: "", // 工程名称
        fEngineeringlocation: "", // 工程地点
        fEngineeringinfo: "", // 工程信息简述
        fDesignfile: "", // 设计资料文件id
        fPiercount: "", // 墩台数量
        fFoundationcount: "", // 基桩数量
        fRegistrantid: "", // 登记人id
        fRegistrantname: "", // 登记人名称
        fRegistdates: "", // 登记时间
        // 当前用户数据
        userId: "", // 当前登陆用户id
        userName: "", // 当前登陆用户名称
        recordfiles: [], //删除文件id集合--修改时传
      },
      row: null,
      formLabelWidth: "80px",
      tableData: [], //表格数据列表
      dialogVisible: false,
    };
  },
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("GxEmbedded_userInfo"));
    this.getList.fUserid = this.userInfo.userId;
  },
  mounted() {
    // 获取页面高度
    this.getHeight();
    // 列表
    this.getDataList(this.getList);
    // 按钮权限
    this.btnRole(this.name);
    // 项目名称数据
    this.getProjectIdAndName();
  },
  methods: {
    // 按钮权限
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("GxEmbedded_ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        this.yj_add = btnStr.includes("yj_add"); //新增
        this.yj_edit = btnStr.includes("yj_edit"); //编辑
        this.yj_delete = btnStr.includes("yj_delete"); //删除
        this.yj_submit = btnStr.includes("yj_submit"); //提交
      } else {
        this.yj_add = true;
        this.yj_edit = true;
        this.yj_delete = true;
        this.yj_submit = true;
      }
    },
    openPdf(file) {
      this.dialogPdf = true;
      this.pdfUrl = file.url;
      this.fFileName = file.name;
    },
    // 项目名称选择框
    selectCompany(e) {
      this.formData.fProjectname = e.F_ProjectName;
      this.formData.fProjectid = e.F_ProjectId;
      this.formData.fCompanyname = "";
      this.formData.fCompanyid = "";
      // 施工单位
      this.getCompanyIdAndName(e.F_ProjectId);
      this.getDataList(this.getList);
    },
    // 施工单位选择框
    selectProject(e) {
      this.formData.fCompanyname = e.F_CompanyName;
      this.formData.fCompanyid = e.F_CompanyId;
      this.getDataList(this.getList);
    },
    // 项目名称数据
    getProjectIdAndName() {
      getProjectIdAndName({
        companyId: this.userInfo.companyId, //当前登录用户机构id
        userId: this.userInfo.userId, //当前登录用户id
      })
        .then((res) => {
          if (res.errcode == 0) {
            this.companyList = res.data.projectList;
          } else {
            this.$message.error("项目名称数据", res.msg);
            return false;
          }
        })
        .catch(() => {
          console.log("项目名称数据获取失败");
          return false;
        });
    },
    // 施工单位数据
    getCompanyIdAndName(id) {
      getCompanyIdAndName({ projectId: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.projectList = res.data.companyList;
          } else {
            this.$message.error("施工单位数据", res.msg);
            return false;
          }
        })
        .catch(() => {
          console.log("施工单位数据获取失败");
          return false;
        });
    },
    // 上传附件
    // 移除
    handleRemove(file) {
      this.$refs.upload.handleRemove(file);
      for (let index = 0; index < this.fPhotofilelist.length; index++) {
        if (file.uid == this.fPhotofilelist[index].uid) {
          if (this.fPhotofilelist[index].atta == undefined) {
            this.formData.recordfiles.push({
              fId: this.fPhotofilelist[index].fId,
            });
          } else {
            this.formData.recordfiles.push({
              fId: this.fPhotofilelist[index].atta.fId,
            });
          }
          this.fPhotofilelist.splice(index, 1);
        }
      }
    },
    // 预览
    handlePictureCardPreview(file) {
      for (let i = 0; i < this.$el.querySelectorAll(".images").length; i++) {
        if (
          file.url ===
          this.$el.querySelectorAll(".images")[i].getElementsByTagName("img")[0]
            .src
        ) {
          const viewer = this.$el.querySelectorAll(".images")[i].$viewer;
          viewer.show();
          break;
        }
      }
    },
    // 操作按钮
    operation() {
      this.dialogTableVisibleTexts = true;
    },
    // 上传文件
    handleChange(res) {
      this.enclosureImg = new FormData(); //new一个formData事件
      this.enclosureImg.append("folderid", this.timestamp1); //将file属性添加到formData里
      this.enclosureImg.append("file", res.raw); //将file属性添加到formData里
      this.enclosureImg.append("userId", this.userInfo.userId); //将file属性添加到formData里
      this.enclosureImg.append("userName", this.userInfo.realName); //将file属性添加到formData里
      upload(this.enclosureImg).then((i) => {
        i[0]["name"] = res.name;
        i[0]["url"] = res.url;
        this.fPhotofilelist.push(i[0]);
      });
    },
    // 保存上传图片
    submitUpload() {
      this.dialogTableVisibleTexts = false;
      this.fSourcefileList = this.imgList.length - this.recordfilesList.length;
    },
    // 点击待办已办
    modelType(e) {
      this.fId = "";
      if (e == "待办") {
        this.flagNum = 0;
        this.getList.modelType = "0";
        this.dis = false;
      } else {
        this.getList.modelType = "1";
        this.flagNum = 1;
        this.dis = true;
      }
      this.getDataList(this.getList);
    },
    // 获取列表数据
    getDataList(id) {
      this.loading = true;
      getPierProjectPageList(id)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.loading = false;
            that.tableData = res.data.pierProjectInfo.list;
            this.queryCriteriaData = res.data.pierProjectInfo;
            this.navigatepageNums =
              this.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("获取列表数据", res.msg);
            this.loading = false;
            return false;
          }
        })
        .catch(() => {
          console.log("获取列表数据失败");
          this.loading = false;
        });
    },

    // 查看
    editText() {
      if (this.fId != null && this.fId != "") {
        this.dialogText = "编辑";
        this.dialogTableVisibleText = true;
        this.loadingDialogText = true;
        getPierProjectByFid({ fId: this.fId })
          .then((res) => {
            console.log(res);
            if (res.errcode == 0) {
              var that = this;
              that.loadingDialogText = false;
              this.timestamp1 = res.data.lrCheckPierproject.fDesignfile;
              that.formData = res.data.lrCheckPierproject;
              that.formData.recordfiles = []; //删除文件id集合--修改时传
              that.fPhotofilelist = res.data.designFile;
            } else {
              this.$message.error("编辑", res.msg);
              this.loadingDialogText = false;
            }
          })
          .catch(() => {
            console.log("编辑接口出错");
            this.loadingDialogText = false;
          });
      } else {
        return this.$message.error("请先选择需要编辑的数据");
      }
    },

    // 新增/编辑
    edit(num) {
      this.formData = {
        fId: "", // 工程信息fid  有值时表示修改  其余表示新增
        fCompanyid: "", // 施工单位id
        fCompanyname: "", // 施工单位名称
        fProjectid: "", // 项目id
        fProjectname: "", // 项目名称
        fEngineeringname: "", // 工程名称
        fEngineeringlocation: "", // 工程地点
        fEngineeringinfo: "", // 工程信息简述
        fDesignfile: "", // 设计资料文件id
        fPiercount: "", // 墩台数量
        fFoundationcount: "", // 基桩数量
        fRegistrantid: "", // 登记人id
        fRegistrantname: "", // 登记人名称
        fRegistdates: "", // 登记时间
        // 当前用户数据
        userId: "", // 当前登陆用户id
        userName: "", // 当前登陆用户名称
        recordfiles: [], //删除文件id集合--修改时传
      };
      this.flagNum = 0;
      this.dis = false;

      if (num == 0) {
        // 新增
        if (this.getList.fUserid != "System") {
          this.timestamp1 = "EQUIP" + Date.parse(new Date());
          this.formData.fDesignfile = this.timestamp1;
          this.formData.userId = this.userInfo.userId;
          this.formData.userName = this.userInfo.realName;
          this.formData.fRegistrantid = this.userInfo.userId;
          this.formData.fRegistrantname = this.userInfo.realName;
          this.dialogText = "新增";
          this.fPhotofilelist = [];
          this.dialogTableVisibleText = true;
        } else {
          this.$message.warning("该用户无法新增");
        }
      } else {
        // 编辑
        this.editText();
      }
    },
    // 保存
    submitForm(formName) {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.loadingDialogText = true;
          addPierProject(this.formData)
            .then((res) => {
              if (res.errcode == 0) {
                this.$message.success("保存成功");
                this.dialogTableVisibleText = false;
                this.loadingDialogText = false;
                this.getDataList(this.getList);
                this.$refs[formName].resetFields();
              } else {
                this.$message.error("保存失败", res.msg);
                this.loadingDialogText = false;
              }
            })
            .catch(() => {
              console.log("保存失败");
              this.loadingDialogText = false;
            });
        } else {
          this.$message.error("请填写必填项");
          return false;
        }
      });
    },
    // 提交
    SubmitText(id) {
      if (id != "" && id != null) {
        this.$confirm("是否继续提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            submitPierProject({ fId: id })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.getDataList(this.getList);
                  this.$message.success("提交成功");
                } else {
                  this.$message.error("提交失败", res.msg);
                  this.loading = false;
                  return false;
                }
              })
              .catch(() => {
                this.loading = false;
                console.log("提交失败");
              });
          })
          .catch(() => {
            this.$message("取消提交");
          });
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },
    // 删除
    rowDelete(id) {
      if (id != "" && id != null) {
        this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            deletePierProjectByFid({ fId: id })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.getDataList(this.getList);
                  this.$message.success("删除成功");
                } else {
                  this.$message.error("删除失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("删除失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消删除");
          });
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },
    // 关闭
    resetForm() {
      this.dialogTableVisible = false;
      this.dialogTableVisibleText = false;
      this.dialogTableVisibleTexts = false;
    },

    // 点击当前行
    getRowInfo(e) {
      this.row = e;
      this.fId = e.fId;
    },
    // 点击设备编码
    openDialog(row) {
      this.fId = row.fId;
      this.flagNum = 1;
      this.dis = true;

      this.editText(this.fId);
    },
    // 点击当前行变色
    rowChange(val) {
      this.currentRow = val;
    },
    // 获取页面容器高度
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      this.dialogHeight = h * 0.5 + "px";
      this.dialogHeights = h * 0.888 + "px";
    },
  },
};
</script>
<style scoped>
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

a {
  text-decoration: none;
  color: #000;
}

.pageFlagText {
  color: #171a1d;
  font-size: 16px;
}
</style>